/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Simulation.Messages;

import Simulation.Messages.Message;

/**
 *
 * @author aking2
 */
public class HealthMessage extends Message {
    
    public HealthMessage(
      byte simulatorIn,
      byte serviceIn,
      byte simStatusIn,
      byte healthStatusIn) {
        
        messageID   = Simulation.Messages.Message.MessageIdEnum.IOS_HEALTH;
        messageData = new byte[MessageSize(messageID)];
        SetSimStatus( simStatusIn );
        SetHealthStatus(healthStatusIn);
        SetService( serviceIn );
        SetSimulator( simulatorIn );
    }  
    
    public HealthMessage(Message msg) {
        this.messageID = msg.messageID;
        this.messageData = msg.messageData;
    }    
    
    public final void SetSimulator(byte s) {
        messageData[0] = s;     
    }      
    
    public final void SetService(byte s) {
        messageData[1] = s;     
    }          
    
    public final void SetSimStatus(byte s) {
        messageData[2] = s;     
    }   
    
    public final void SetHealthStatus(byte s) {
        messageData[3] = s;     
    }    
    
   

    public byte GetSimulator() {
        return messageData[0];
    }   
    
    public byte GetService() {
        return messageData[1];
    }       
    
     public byte GetSimStatus() {
        return messageData[2];
    } 
     
    public byte GetHealthStatus() {
        return messageData[3];
    }      

    public static String StringForStatus( byte status) {
        String result;
        switch (status) {

            case STATUS_HEALTHY:
                result = "Good";
                break;
            case STATUS_ERROR:
                result = "Error";
                break;
            case STATUS_OVERRUN:
                result = "Over-Run";
                break;   
            default:
                result = "Unknown";
                break;                
        }
        return result;
    }

    public static final byte STATUS_UNKNOWN = 0;
    public static final byte STATUS_HEALTHY = 1;
    public static final byte STATUS_ERROR   = 2;
    public static final byte STATUS_OVERRUN = 3;        
}
